<!DOCTYPE html>
<html>
<head>
  	<title>业务支撑系统</title>
  	<#import "/common/common.js.ftl" as netCommon>
	<@netCommon.commonStyle />
	<!-- DataTables -->
  	<link rel="stylesheet" href="${request.contextPath}/static/adminlte/plugins/datatables/dataTables.bootstrap.css">
    <link rel="stylesheet" href="${request.contextPath}/static/adminlte/bootstrap/css/bootstrap-select.css">
    <link href="${request.contextPath}/static/plugins/table/bootstrap-table.min.css" rel="stylesheet" />
    <link href="${request.contextPath}/static/plugins/bootstrap-wizard/wizard.css" rel="stylesheet" />

</head>
<body class="hold-transition skin-blue sidebar-mini <#if cookieMap?exists && "off" == cookieMap["xxljob_adminlte_settings"].value >sidebar-collapse</#if>">
		<!-- Content Header (Page header) -->
		<section class="content-header">
			<h1>算法任务管理<small>业务支撑系统</small></h1>
			<!--
			<ol class="breadcrumb">
				<li><a><i class="fa fa-dashboard"></i>调度管理</a></li>
				<li class="active">调度中心</li>
			</ol>
			-->
		</section>

		<!-- Main content -->
	    <section class="content">

	    	<div class="row">
	    		<div class="col-xs-4">
	              	<div class="input-group">
	                	<span class="input-group-addon">节点</span>
                		<select class="form-control" id="jobGroup" >
                			<#list JobGroupList as group>
                				<option value="${group.id}" <#if jobGroup==group.id>selected</#if> >${group.title}</option>
                			</#list>
	                  	</select>
	              	</div>
	            </div>
                <div class="col-xs-4">
                    <div class="input-group">
                        <span class="input-group-addon">任务名称</span>
                        <input type="text" class="form-control" id="executorHandler" autocomplete="on" >
                    </div>
                </div>
	            <div class="col-xs-2">
	            	<button class="btn btn-block btn-info" id="searchBtn">搜索</button>
	            </div>
	            <div class="col-xs-2">
                    <@shiro.hasPermission name="taskadd"><button class="btn btn-block btn-success add" type="button">+新增任务</button></@shiro.hasPermission>
	            </div>
          	</div>

			<div class="row">
				<div class="col-xs-12">
					<div class="box">
			            <div class="box-header hide">
			            	<h3 class="box-title">调度列表</h3>
			            </div>
			            <div class="box-body" >
			              	<table id="job_list" class="table table-bordered table-striped">
				                <thead>
					            	<tr>
					            		<th name="id" >id</th>
					                	<th name="jobGroup" >jobGroup</th>
                                        <!--<th name="childJobKey" >JobKey</th>-->
					                  	<th name="jobDesc" >任务名称</th>
                                        <th name="nextfireTime" >下次执行时间</th>
                                        <th name="prevfireTime" >准备</th>
                                        <th name="glueType" >运行模式</th>
					                  	<th name="executorParam" >任务参数</th>
                                        <th name="jobCron" >执行策略</th>
					                  	<th name="addTime" >新增时间</th>
					                  	<th name="updateTime" >更新时间</th>
					                  	<th name="author" >负责人</th>
					                  	<th name="alarmEmail" >报警邮件</th>
					                  	<th name="glueType" >运行模式</th>
					                  	<th name="jobStatus" >状态</th>
					                  	<th>操作</th>
					                </tr>
				                </thead>
				                <tbody></tbody>
				                <tfoot></tfoot>
							</table>
						</div>
					</div>
				</div>
			</div>
	    </section>

	<!-- footer -->

<!-- job新增.模态框 -->
<div class="modal fade" id="addModal" tabindex="-1" role="dialog"  aria-hidden="true">
	<div class="modal-dialog modal-lg">
		<div class="modal-content">
			<div class="modal-header">
            	<h4 class="modal-title" >新增任务</h4>
         	</div>
         	<div class="modal-body">
				<form class="form-horizontal form" role="form" >
                    <div id="rootwizard">
                        <ul>
                            <li><a href="#tab1" data-toggle="tab"><span class="label">1</span> 任务参数</a></li>
                            <li><a href="#tab2" data-toggle="tab"><span class="label">2</span> 固定参数</a></li>
                            <li><a href="#tab3" data-toggle="tab"><span class="label">3</span> 输入参数</a></li>

                        </ul>
                        <div class="tab-content">
                            <div class="tab-pane" id="tab1">
								<hr>
                                <div class="form-group">
                                    <label for="firstname" class="col-sm-2 control-label">节点<font color="red">*</font></label>
                                    <div class="col-sm-4">
                                        <select class="form-control" name="jobGroup" >
										<#list JobGroupList as group>
                                            <option value="${group.id}" <#if jobGroup==group.id>selected</#if> >${group.title}</option>
										</#list>
                                        </select>
                                    </div>
                                    <label for="lastname" class="col-sm-2 control-label">任务名称<font color="red">*</font></label>
                                    <div class="col-sm-4"><input type="text" class="form-control" name="jobDesc" placeholder="请输入“任务名称”" maxlength="50" ></div>
                                </div>
                                <div class="form-group">
                                    <label for="firstname" class="col-sm-2 control-label">路由策略<font color="red">*</font></label>
                                    <div class="col-sm-4">
                                        <select class="form-control" name="executorRouteStrategy" >
										<#list ExecutorRouteStrategyEnum as item>
                                            <option value="${item}" >${item.title}</option>
										</#list>
                                        </select>
                                    </div>
                                    <label for="lastname" class="col-sm-2 control-label">执行策略<font color="red">*</font></label>
                                    <div class="col-sm-4"><input type="text" class="form-control" name="jobCron" placeholder="请输入“执行策略”" maxlength="20" ></div>
                                </div>
                                <div class="form-group">
                                    <label for="firstname" class="col-sm-2 control-label">产品<font color="red">*</font></label>
                                    <div class="col-sm-4">
                                        <select class="form-control selectpicker show-tick productId"  data-live-search="true"  name="productId"  >
										<#list productList as item>
                                            <option value="${item.id}" >${item.name}</option>
										</#list>
                                        </select>
                                    </div>
                                    <label for="firstname" class="col-sm-2 control-label">JobHandler<font color="black">*</font></label>
                                    <div class="col-sm-4">
                                        <select class="form-control selectpicker show-tick modelId"  data-live-search="true" name="modelId" >
										<#list executorHandlerlist as item>
                                            <option value="${item.id}" >${item.modelName}</option>
										</#list>
                                        </select>
                                    </div>
                                </div>
							<#--<div class="form-group">
                                <label for="firstname" class="col-sm-2 control-label">执行参数<font color="black">*</font></label>
                                <div class="col-sm-4"><input type="text" class="form-control" name="executorParam" placeholder="请输入“执行参数”" maxlength="100" ></div>
                                <label for="lastname" class="col-sm-2 control-label">子任务Key<font color="black">*</font></label>
                                <div class="col-sm-4"><input type="text" class="form-control" name="childJobKey" placeholder="请输入子任务的任务Key,如存在多个逗号分隔" maxlength="100" ></div>
                            </div>-->
                                <div class="form-group">
                                    <label for="firstname" class="col-sm-2 control-label">阻塞处理策略<font color="red">*</font></label>
                                    <div class="col-sm-4">
                                        <select class="form-control" name="executorBlockStrategy" >
										<#list ExecutorBlockStrategyEnum as item>
                                            <option value="${item}" >${item.title}</option>
										</#list>
                                        </select>
                                    </div>
                                    <label for="lastname" class="col-sm-2 control-label">失败处理策略<font color="red">*</font></label>
                                    <div class="col-sm-4">
                                        <select class="form-control" name="executorFailStrategy" >
										<#list ExecutorFailStrategyEnum as item>
                                            <option value="${item}" >${item.title}</option>
										</#list>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="lastname" class="col-sm-2 control-label">子任务key<font color="red">*</font></label>
                                    <div class="col-sm-4">
                                        <input type="text" class="form-control" name="childJobKey" placeholder="请输入子任务的任务Key,如存在多个逗号分隔" maxlength="100" >
                                    </div>
                                    <label for="lastname" class="col-sm-2 control-label">报警邮件<font color="black">*</font></label>
                                    <div class="col-sm-4"><input type="text" class="form-control" name="alarmEmail" placeholder="请输入“报警邮件”，多个邮件地址逗号分隔" maxlength="100" ></div>
                                </div>
                            </div>
                            <div class="tab-pane" id="tab2">
                                <div class="form-group">
                                    <div class="col-sm-12">
                                        <div id="reportTable3Div" ></div>
                                        <div id="reportTable3" class="table table-bordered table-striped text-nowrap" ></div>
                                    </div>
                                </div>

							</div>
                            <div class="tab-pane" id="tab3">
                                <div class="form-group">
                                    <div class="col-sm-12">
                                        <div id="reportTable4Div" ></div>
                                        <div id="reportTable4" class="table table-bordered table-striped text-nowrap"></div>
                                    </div>
                                </div>

							</div>
                            <ul class="pager wizard">
                                <li class="previous first" style="display:none;"><a href="#">First</a></li>
                                <li class="previous"><a href="#">上一步</a></li>
                                <li class="next last" style="display:none;"><a href="#">Last</a></li>
                                <li class="next"><a href="#">下一步</a></li>
                            </ul>
                        </div>
                    </div>

					<hr>
					<div class="form-group">
						<div class="col-sm-offset-3 col-sm-6">
							<button type="submit" class="btn btn-primary"  >保存</button>
							<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
						</div>
					</div>
<input type="hidden" name="author" value="admin">
<input type="hidden"  name="glueType" value="BEAN">
<input type="hidden"  name="executorParam">
<input type="hidden"  name="fixedParameter">
<input type="hidden"  name="dynamicParameter" >
<input type="hidden"  name="executorHandler" >
<input type="hidden"  name="modelParameters" >
<input type="hidden"  id="tasktype" name="tasktype" value="${tasktype}" >
<input type="hidden" name="glueRemark" value="GLUE代码初始化" >
<textarea name="glueSource" style="display:none;" ></textarea>
<textarea class="glueSource_java" style="display:none;" >
package com.xxl.job.service.handler;

import com.xxl.job.core.log.XxlJobLogger;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;

public class DemoGlueJobHandler extends IJobHandler {

	@Override
	public ReturnT<String> execute(String... params) throws Exception {
		XxlJobLogger.log("XXL-JOB, Hello World.");
		return ReturnT.SUCCESS;
	}

}
</textarea>
<textarea class="glueSource_shell" style="display:none;" >
#!/bin/bash
echo "xxl-job: hello shell"

echo "脚本位置：$0"
echo "参数数量：$#"
for param in $*
do
    echo "参数 : $param"
    sleep 1s
done

echo "Good bye!"
exit 0
</textarea>
<textarea class="glueSource_python" style="display:none;" >
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import time
import sys

print "xxl-job: hello python"
print "脚本文件：", sys.argv[0]
for i in range(1, len(sys.argv)):
	time.sleep(1)
	print "参数", i, sys.argv[i]

print "Good bye!"
exit(0)<#--
import logging
logging.basicConfig(level=logging.DEBUG)
logging.info("脚本文件：" + sys.argv[0])
-->
</textarea>
<textarea class="glueSource_nodejs" style="display:none;" >
#!/usr/bin/env node
console.log("xxl-job: hello nodejs")

var arguments = process.argv

console.log("脚本文件: " + arguments[1])
for (var i = 2; i < arguments.length; i++){
	console.log("参数 %s = %s", (i-1), arguments[i]);
}

console.log("Good bye!")
process.exit(0)
</textarea>
				</form>
         	</div>
		</div>
	</div>
</div>

<!-- 更新.模态框 -->
<div class="modal fade" id="updateModal" tabindex="-1" role="dialog"  aria-hidden="true">
	<div class="modal-dialog modal-lg">
		<div class="modal-content">
			<div class="modal-header">
            	<h4 class="modal-title" >更新任务</h4>
         	</div>
         	<div class="modal-body">
				<form class="form-horizontal form" role="form" >
                    <div id="rootwizard1">
                        <ul>
                            <li><a href="#tab4" data-toggle="tab"><span class="label">1</span> 任务参数</a></li>
                            <li><a href="#tab5" data-toggle="tab"><span class="label">2</span> 固定参数</a></li>
                            <li><a href="#tab6" data-toggle="tab"><span class="label">3</span> 输入参数</a></li>

                        </ul>
                        <div class="tab-content">
                            <div class="tab-pane" id="tab4">
                                <hr>
                                <div class="form-group">
                                    <label for="firstname" class="col-sm-2 control-label">执行器<font color="red">*</font></label>
                                    <div class="col-sm-4">
                                        <select class="form-control" name="jobGroup" disabled >
										<#list JobGroupList as group>
                                            <option value="${group.id}" >${group.title}</option>
										</#list>
                                        </select>
                                    </div>
                                    <label for="lastname" class="col-sm-2 control-label">任务名称<font color="red">*</font></label>
                                    <div class="col-sm-4"><input type="text" class="form-control" name="jobDesc" placeholder="请输入“任务名称”" maxlength="50" ></div>
                                </div>
                                <div class="form-group">
                                    <label for="firstname" class="col-sm-2 control-label">路由策略<font color="red">*</font></label>
                                    <div class="col-sm-4">
                                        <select class="form-control" name="executorRouteStrategy" >
										<#list ExecutorRouteStrategyEnum as item>
                                            <option value="${item}" >${item.title}</option>
										</#list>
                                        </select>
                                    </div>
                                    <label for="lastname" class="col-sm-2 control-label">执行策略<font color="red">*</font></label>
                                    <div class="col-sm-4"><input type="text" class="form-control" name="jobCron" placeholder="请输入“执行策略”" maxlength="20" ></div>
                                </div>
                                <div class="form-group">

								<#--
                                 <label for="firstname" class="col-sm-2 control-label">运行模式<font color="red">*</font></label>
                                 <div class="col-sm-4">
                                     <select class="form-control glueType" name="glueType" disabled >
                                     <#list GlueTypeEnum as item>
                                         <option value="${item}" >${item.desc}</option>
                                     </#list>
                                     </select>
                                 </div>-->
                                    <label for="firstname" class="col-sm-2 control-label">产品<font color="red">*</font></label>
                                    <div class="col-sm-4">
                                        <select class="form-control selectpicker show-tick productId"  data-live-search="true"  name="productId"  >
										<#list productList as item>
                                            <option value="${item.id}" >${item.name}</option>
										</#list>
                                        </select>
                                    </div>
                                    <label for="firstname" class="col-sm-2 control-label">模型<font color="black">*</font></label>
                                    <div class="col-sm-4">
                                        <select class="form-control selectpicker show-tick modelId"  data-live-search="true" name="modelId" >
										<#list executorHandlerlist as item>
                                            <option value="${item.id}" >${item.modelName}</option>
										</#list>
                                        </select>
                                    </div>
                                </div>
							<#--				<div class="form-group">
                                                <label for="firstname" class="col-sm-2 control-label">执行参数<font color="black">*</font></label>
                                                <div class="col-sm-4"><input type="hidden" class="form-control" name="executorParam" placeholder="请输入“执行参数”" id="executorParam1" maxlength="100" ></div>
                                                <label for="lastname" class="col-sm-2 control-label">子任务Key<font color="black">*</font></label>
                                                <div class="col-sm-4"><input type="text" class="form-control" name="childJobKey" placeholder="请输入子任务的任务Key,如存在多个逗号分隔" maxlength="100" ></div>
                                            </div>-->
                                <div class="form-group">
                                    <label for="firstname" class="col-sm-2 control-label">阻塞处理策略<font color="red">*</font></label>
                                    <div class="col-sm-4">
                                        <select class="form-control" name="executorBlockStrategy" >
										<#list ExecutorBlockStrategyEnum as item>
                                            <option value="${item}" >${item.title}</option>
										</#list>
                                        </select>
                                    </div>
                                    <label for="lastname" class="col-sm-2 control-label">失败处理策略<font color="red">*</font></label>
                                    <div class="col-sm-4">
                                        <select class="form-control" name="executorFailStrategy" >
										<#list ExecutorFailStrategyEnum as item>
                                            <option value="${item}" >${item.title}</option>
										</#list>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="lastname" class="col-sm-2 control-label">子任务key<font color="red">*</font></label>
                                    <div class="col-sm-4">
                                        <input type="text" class="form-control" name="childJobKey" placeholder="请输入子任务的任务Key,如存在多个逗号分隔" maxlength="100" >
                                    </div>
                                    <label for="lastname" class="col-sm-2 control-label">报警邮件<font color="black">*</font></label>
                                    <div class="col-sm-4"><input type="text" class="form-control" name="alarmEmail" placeholder="请输入“报警邮件”，多个邮件地址逗号分隔" maxlength="100" ></div>
                                </div>
                            </div>
                            <div class="tab-pane" id="tab5">
                                <div class="form-group">
                                    <div class="col-sm-12">
                                        <div id="reportTable1Div" ></div>
                                        <div id="reportTable1" class="table table-bordered table-striped text-nowrap" ></div>
                                    </div>
                                </div>

                            </div>
                            <div class="tab-pane" id="tab6">
                                <div class="form-group">
                                    <div class="col-sm-12" >
                                        <div id="reportTable2Div" ></div>
                                        <!--class="table table-bordered table-striped" style="word-break:break-all;" -->
                                        <div id="reportTable2" class="table table-bordered table-striped text-nowrap"  ></div>
                                    </div>
                                </div>

                            </div>
                            <ul class="pager wizard">
                                <li class="previous first" style="display:none;"><a href="#">First</a></li>
                                <li class="previous"><a href="#">上一步</a></li>
                                <li class="next last" style="display:none;"><a href="#">Last</a></li>
                                <li class="next"><a href="#">下一步</a></li>
                            </ul>
                        </div>
                    </div>


					<hr>
					<div class="form-group">
						<div class="col-sm-offset-3 col-sm-6">
							<button type="submit" class="btn btn-primary"  >保存</button>
							<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
							<input type="hidden" name="id" >
						</div>
					</div>
					<input type="hidden" name="author" >

					<input type="hidden"  name="glueType" value="BEAN">
					<input type="hidden"  name="executorParam">
					<input type="hidden"  name="fixedParameter">
					<input type="hidden"  name="dynamicParameter" >
					<input type="hidden"  name="executorHandler" >
                    <input type="hidden"  name="modelParameters" >

                </form>
         	</div>
		</div>
	</div>
</div>
<@netCommon.commonScript />
<script src="${request.contextPath}/static/adminlte/plugins/daterangepicker/moment.min.js"></script>
<script src="${request.contextPath}/static/adminlte/plugins/daterangepicker/daterangepicker.js"></script>
<!-- DataTables -->
<script src="${request.contextPath}/static/adminlte/plugins/datatables/jquery.dataTables.min.js"></script>
<script src="${request.contextPath}/static/adminlte/plugins/datatables/dataTables.bootstrap.min.js"></script>
<script src="${request.contextPath}/static/plugins/jquery/jquery.validate.min.js"></script>
<!-- moment -->
<script src="${request.contextPath}/static/plugins/My97DatePicker/WdatePicker.js"></script>
<script src="${request.contextPath}/static/adminlte/plugins/daterangepicker/moment.min.js"></script>
<script>
    function getbutton(row,logUrl,codeBtn,pause_resume) {
        var html = '<p id="'+ row.id +'" >'+
                '<@shiro.hasPermission name="executeonce"><button class="btn btn-primary btn-xs job_operate" _type="job_trigger" type="button">执行一次</button> </@shiro.hasPermission>'+
                '<@shiro.hasPermission name="executepause">'+pause_resume+'</@shiro.hasPermission>'+
                '<@shiro.hasPermission name="tasklog"><button class="btn btn-primary btn-xs" type="job_del" type="button" onclick="windowOpen(\'' + logUrl + '\')" >日志</button></@shiro.hasPermission>  '+
                '<@shiro.hasPermission name="taskedit"><button class="btn btn-warning btn-xs update" type="button">编辑</button></@shiro.hasPermission>  '+
                codeBtn +
                '<@shiro.hasPermission name="taskdel"><button class="btn btn-danger btn-xs job_operate" _type="job_del" type="button">删除</button></@shiro.hasPermission>  '+
                '</p>';
        return html;
    }
</script>
<script src="${request.contextPath}/static/js/jobinfo.index.1.js"></script>
<script src="${request.contextPath}/static/adminlte/bootstrap/js/bootstrap-select.min.js"></script>
<script src="${request.contextPath}/static/plugins/table/bootstrap-table.min.js"></script>
<script src="${request.contextPath}/static/plugins/table/bootstrap-table-edit1.js"></script>
<script src="${request.contextPath}/static/plugins/table/bootstrap-select.js"></script>

<script src="${request.contextPath}/static/plugins/bootstrap-wizard/jquery.bootstrap.wizard.min.js"></script>
<script>


    $('#rootwizard').bootstrapWizard({'tabClass': 'bwizard-steps'});
    $('#rootwizard1').bootstrapWizard({'tabClass': 'bwizard-steps'});
    function windowOpen(url) {
        window.open(url,"_self");
        
    }

</script>


</body>
</html>
